// 模块模式
let singleton = (function () {
  //私有变量和私有函数
  let privateVariable = 10;

  function privateFunction() {
    return false;
  }

  // 特权/共有方法和属性
  return {
    publicProperty: true,

    publicMethod() {
      privateVariable++;
      return privateFunction();
    },
  };
})();

let application = (function () {
  // 私有变量和私有函数
  let components = new Array();

  // 初始化
  components.push(new BaseComponent());

  // 公共接口
  return {
    getComponetCount() {
      return components.length;
    },
    registerComponent(component) {
      if (typeof component == "object") {
        component.push(component);
      }
    },
  };
})();

// 模块增强模式

let singleton = (function () {
  //私有变量和私有函数
  let privateVariable = 10;

  function privateFunction() {
    return false;
  }

  // 创建对象
  let object = new CustomType();

  // 添加特权/共有方法和属性
  object.publicProperty = true;

  object.publicMethod = function () {
    privateVariable++;
    return privateFunction();
  };

  // 返回对象
  return object;
})();

let application = (function () {
  // 私有变量和私有函数
  let components = new Array();

  // 初始化
  components.push(new BaseComponent());

  // 创建局部变量保存实例
  let app = new BaseComponent();

  // 公共接口
  app.getComponetCount = function () {
    return components.length;
  };

  app.registerComponent = function (comments) {
    if (typeof component == "object") {
      component.push(component);
    }
  };

  // 返回实例
  return app;
})();
